/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __INPUT_SYSTEM_H__
#define __INPUT_SYSTEM_H__

#include "Ogre.h"
#include <OIS/OIS.h>
#include "SceneObject.h"

namespace PQGame
{
	class InputSystem
		: public OIS::KeyListener, public OIS::MouseListener
	{
	protected:
		InputSystem(void);
		~InputSystem(void);
		bool keyPressed( const OIS::KeyEvent &e);
		bool keyReleased( const OIS::KeyEvent &e);

		bool mouseMoved( const OIS::MouseEvent &e);
		bool mousePressed( const OIS::MouseEvent &e, OIS::MouseButtonID id);
		bool mouseReleased( const OIS::MouseEvent &e, OIS::MouseButtonID id);
	public:
		static InputSystem& getSingleton();
		void init(PQEngine::SceneObject* sceneObject);
		void capture();
		void setWindowExtents(int width,int height);

		void addKeyListener( OIS::KeyListener *keyListener, const std::string& instanceName);
		void addMouseListener( OIS::MouseListener *mouseListener, const std::string& instanceName);

		void removeKeyListener( const std::string& instanceName);
		void removeMouseListener( const std::string& instanceName);
	private:
		Ogre::RenderWindow *renderWindow;
		OIS::InputManager *inputManager;
		OIS::Mouse  *mouse;
		OIS::Keyboard *keyboard;

		std::map<std::string, OIS::KeyListener*> keyListeners;
		std::map<std::string, OIS::MouseListener*> mouseListeners;
	};
}
#endif
